package com.group.Servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.group.pojo.GStudent;

@WebServlet("/StudentInfoServlet")
public class StudentInfoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public StudentInfoServlet() {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取请求动作
		String action = request.getParameter("action");
		
		if(action.equals("update")) {
			String studentID = request.getParameter("studentID");
			String studentName = request.getParameter("studentName");
			GStudent s = new GStudent();
			s.updateStudentName(studentID, studentName);
			response.sendRedirect("ClassInfoServlet?action=info");
		}
		else if(action.equals("updateGroup")) {
			String[] studentID = request.getParameterValues("studentID");
			String groupID = request.getParameter("groupID");
			GStudent s = new GStudent();
			s.updateStudentGruopIDByID(Integer.parseInt(groupID), studentID);
			response.sendRedirect("GroupInfoServlet?action=info");
		}
		
		
	}

}
